home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / include / handleP.h < prev    next >
C/C++ Source or Header  |  1993-01-08  |  4KB  |  116 lines

  1. /* Copyright (c) 1992 The Geometry Center; University of Minnesota
  2.    1300 South Second Street;  Minneapolis, MN  55454, USA;
  3.    
  4. This file is part of geomview/OOGL. geomview/OOGL is free software;
  5. you can redistribute it and/or modify it only under the terms given in
  6. the file COPYING, which you should have received along with this file.
  7. This and other related software may be obtained via anonymous ftp from
  8. geom.umn.edu; email: software@geom.umn.edu. */
  9.  
  10. /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips */
  11.  
  12. #ifndef _HANDLEPOOLP_
  13. #define _HANDLEPOOLP_
  14. /*
  15.  * Communications -- Private definitions for Pools and Handles.
  16.  */
  17. #include "ooglutil.h"
  18. #include "streampool.h"
  19. /*#include "sm.h"*/
  20.  
  21. #define    HANDLEMAGIC    OOGLMagic('h',1)
  22.  
  23. typedef struct HRef {
  24.     Handle    **hp;
  25.     Ref    *parentobj;
  26.     void    *info;
  27.     void    (*update) P((Handle **, Ref *, void *));
  28. } HRef;
  29.  
  30. struct Handle {
  31.     REFERENCEFIELDS
  32.     HandleOps *ops;        /* Comm-related operations on our datatype */
  33.     char    *name;        /* Char-string name */
  34.     Ref    *object;    /* Current object value if any */
  35.     Handle    *next;        /* Link in list of all handles */
  36.     Pool    *whence;    /* Where did this handle's value come from? */
  37.  
  38.     int    maxrefs;    /* Resizable array of references */
  39.     int    nrefs;        /*  to this Handle, which we update */
  40.     HRef    *refs;        /*  when the Handle's object changes. */
  41.  
  42.     int    permanent;    /* Retain even when last reference goes away? */
  43.     /*
  44.      * Pool-type-specific state
  45.      */
  46. #if 0
  47.         SMSym    *sym;        /* Address of our SM symbol */
  48.         int    version;    /* Version number of shared-memory symbol */
  49.         Pool    *smpool;    /* Pool in which our symbol lies */
  50.         Handle    *samepool;    /* Link in list of handles on this pool */
  51. #endif
  52. };
  53.  
  54. #define    P_SM    1
  55. #define    P_STREAM 2
  56.  
  57. struct Pool {
  58.     int    type;        /* P_SM or P_STREAM */
  59.     Pool    *next;        /* Link in list of all Pools */
  60.     char    *poolname;    /* Name of this pool: typically a filename */
  61.     Handle    *handles;    /* All handles using this Pool */
  62.     HandleOps *ops;        /* I/O operations */
  63.  
  64.     long    await;        /* Unix time until which we should wait */
  65.     int    (*resyncing)();    /* We're resyncing, call this ... if non-NULL */
  66.  
  67.     /*
  68.      * State for P_STREAM pools.
  69.      */
  70.  
  71.     char    otype;        /* PO_HANDLES, PO_DATA, PO_ALL */
  72.     char    mode;        /* read/write status: 0, 1, 2 as with open() */
  73.     char    seekable;    /* 1 for plain file, 0 for pipe/socket */
  74.     char    softEOF;    /* Can we hope to read more after EOF?
  75.                  * 1 for tty or named pipe, 0 otherwise.
  76.                  */
  77.     FILE    *inf;
  78.     FILE    *outf;
  79.  
  80.     short    flags;        /* Miscellaneous internal flags: */
  81. #define      PF_TEMP    1    /*   "Temporary pool" -- not in AllPools list */
  82. #define      PF_ANY    2    /*   any objects read from this Pool? */
  83. #define      PF_REREAD    4    /*   actually re-read on "<" */
  84. #define      PF_CLOSING    0x10    /* Internal flag to avoid PoolClose() recursion */
  85. #define      PF_ASLEEP    0x20    /* PoolSleep() called on this Pool. */
  86. #define      PF_DELETED    0x40    /* Pool is on free list - don't touch! */
  87. #define      PF_NOPREFETCH    0x80    /* Don't let PoolIn() prefetch the first char */
  88.  
  89.     short    level;        /* {} Bracket counter */
  90.  
  91.     long    inf_mtime;    /* modification time of p->inf file */
  92.                 /* A second explicit reference to the same
  93.                  * file can cause it to be re-read if it's
  94.                  * been changed since last time, or if it's
  95.                  * a stream (not seekable).
  96.                  */
  97.  
  98.     struct timeval awaken;    /* Resume reading at this time */
  99.     struct timeval timebase; /* Basis for our clock */
  100.  
  101.     /*
  102.      * State for P_SM pools.
  103.      */
  104. #if 0
  105.         SMRegion *sm;        /* for shared-memory Pools */
  106. #endif
  107.  
  108.     /*
  109.      * client data pointer, used by clients for whatever they want
  110.      */
  111.     void *client_data;
  112.  
  113. };
  114.  
  115. #endif /*_HANDLEPOOLP_*/
  116.